package com.yungu.swift.autoconfig.redis;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;

/***
 * @Description
 * @author xiuyin.cui
 * @date 2019/03/25 15:50
 *
 * @return
 */

@Configuration
public class RedisAutoConfiguration {

    @Value("${yungu.redis.key.prefix}")
    private String keyPrefix;

    @Bean
    @ConditionalOnMissingBean
    public RedisCacheService redisCacheService(RedisTemplate redisTemplate) {
        return new RedisCacheService(keyPrefix, redisTemplate);
    }


    @Bean
    @ConditionalOnMissingBean
    public RedisStringCacheService stringRedisCacheService(StringRedisTemplate stringRedisTemplate) {
        return new RedisStringCacheService(keyPrefix, stringRedisTemplate);
    }
}
